package rmi;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RMIServer {
    public static void main(String[] args) {
        try {
            // 创建RMI注册表（端口1099）
            Registry registry = LocateRegistry.createRegistry(1099);

            // 创建远程对象实例
            HelloService helloService = new HelloServiceImpl();

            // 绑定对象到注册表
            registry.rebind("HelloService", helloService);

            System.out.println("✅ 服务端已启动，等待客户端连接...");
        } catch (Exception e) {
            System.err.println("服务端异常: " + e);
            e.printStackTrace();
        }
    }
}
